package com.kistring.polygyny;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class AcceratorDB extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "tshek";
	private static final int DATABASE_VERSION = 1;

	private static final String TABLE_NAME = "ACCELEROMETER";

	private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS "
			+ TABLE_NAME+ " (" 
			+ "key INTEGER PRIMARY KEY AUTOINCREMENT,"
			+ "name TEXT," 
			+ "age INTEGER," 
			+ "gx FLOAT,"
			+ "gy FLOAT,"
			+ "gz FLOAT,"
			+ "timestamp LONG"
			+ ")";

	public AcceratorDB(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_TABLE);
		Log.i("DB", "Database is created." + db.toString());

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w("DB", "Upgrading database, this will drop tables and recreate.");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
	}

}
